package com.design01_builder.pattern02_factory.simple_factory.service;

import com.alibaba.fastjson.JSON;
import com.design01_builder.pattern02_factory.simple_factory.entry.AwardInfo;
import com.design01_builder.pattern02_factory.simple_factory.entry.ResponseResult;
import com.design01_builder.pattern02_factory.simple_factory.entry.SmallGiftInfo;

import java.util.UUID;

/**
 * @ClassName SmallGiftFreeGoods
 * @Description 小礼品发放服务
 * @Author zhangjunhao
 * @DATE 2023/9/2 1:07
 */
public class SmallGiftFreeGoods implements IFreeGoods {

    @Override
    public ResponseResult sendFreeGoods(AwardInfo awardInfo) {
        SmallGiftInfo smallGiftInfo = new SmallGiftInfo();
        smallGiftInfo.setUserPhone(awardInfo.getExtMap().get("phone"
        ));
        smallGiftInfo.setUserName(awardInfo.getExtMap().get("usernam e"));
                smallGiftInfo.setRelAddress(awardInfo.getExtMap().get("address"));
        smallGiftInfo.setOrderId(UUID.randomUUID().toString());
        System.out.println("小礼品发放成,请注意查收: " +
                JSON.toJSON(smallGiftInfo));
        return new ResponseResult("200","小礼品发送成功",smallGiftInfo);
    }
}
